package com.kksoft.readcm.a;

import android.os.AsyncTask;

import com.kksoft.readcm.activity.App;
import com.kksoft.readcm.activity.RilAppActivity;
import com.kksoft.readcm.objects.ErrorReport;
import com.kksoft.readcm.objects.GlobalVar;
import com.kksoft.readcm.objects.UserInfo;

public final class Appconfig     //old af
{
  private static Appconfig thisaf;
  private UserInfo userInfo;
  private final ItemAppObservable c;                 //old c
  private final LoginAppObservable d;                //old d
  private final SqliteAppObservable fSqliteAppObservable;				//old e
  private final y f;
  private c g;
  private final ah h;
  private final LoginObservable pLoginObservable;             //old i
  private final k j;
  private final am k;
  private final ag l;
  private boolean m;
  private boolean n;
  private boolean o;
  private boolean p;

  public Appconfig()
  {
	  thisaf = this; 
    this.m = false;
    this.n = false;
    this.o = false;
    this.p = false;
    this.userInfo = new UserInfo(App.getSharedPreferences().getString("username", null), App.getSharedPreferences().getString("password", null));
    com.kksoft.readcm.objects.l.Q();
    this.pLoginObservable = new LoginObservable();
    this.c = new ItemAppObservable();
    this.d = new LoginAppObservable();
    SqliteAppObservable localx = new SqliteAppObservable();
    this.fSqliteAppObservable = localx;
    y localy1 = new y();
    this.f = localy1;
    ah localah = new ah();
    this.h = localah;
    k localk = new k();
    this.j = localk;
    am localam1 = new am();
    this.k = localam1;
    c localc = new c();
    this.g = localc;
    ag localag = new ag();
    this.l = localag;
    this.pLoginObservable.a(this);
    LoginObservable localal2 = this.pLoginObservable;
    am localam2 = this.k;
    localal2.addObserver(localam2);
    LoginObservable localal3 = this.pLoginObservable;
    y localy2 = this.f;
    localal3.addObserver(localy2);
    this.c.a(this);
    this.d.a(this);
    this.fSqliteAppObservable.a(this);
    this.f.a(this);
    this.h.a(this);
    this.j.a(this);
    this.k.a(this);
    this.g.a(this);
    this.l.a(this);
  }

  public static Appconfig getThis()
  {
    return thisaf;
  }

  public final SqliteAppObservable a()
  {
    return this.fSqliteAppObservable;
  }

  public final void a(ErrorReport paramErrorReport)
  {
    RilAppActivity localRilAppActivity = App.r();
    if ((this.p) || (localRilAppActivity == null))
    	App.handlerPost(new d(this, localRilAppActivity, paramErrorReport));
  }

  public final void a(String paramString1, String paramString2)
  {
    App.getSharedPreferences().edit().putString("username", paramString1).putString("password", paramString2).commit();
    UserInfo localz = new UserInfo(paramString1, paramString2);
    this.userInfo = localz;
    App.putErrorReporter();
  }

  public final LoginAppObservable b()
  {
    return this.d;
  }

  public final ItemAppObservable getItemAppObservable()  //old c
  {
    return this.c;
  }

  public final y d()
  {
    return this.f;
  }

  public final c e()
  {
    return this.g;
  }

  public final void f()
  {
    c localc = new c();
    this.g = localc;
  }

  public final k g()
  {
    return this.j;
  }

  public final am h()
  {
    return this.k;
  }

  public final ah i()
  {
    return this.h;
  }

  public final LoginObservable getLoginObservable()     //old j
  {
    return this.pLoginObservable;
  }

  public final ag k()
  {
    return this.l;
  }

  public final boolean l()
  {
    return this.m;
  }

  public final boolean m()
  {
    if ((this.n) && (!this.o))
    	return true;
    else
      return false;
  }

  public final void n()
  {
    this.n=true;
    this.m=false;
    LoginObservable localal = this.pLoginObservable;
    GlobalVar localh = new GlobalVar(1);
    localal.a(localh);
    if ((this.userInfo.isUser()) && (App.getSharedPreferences().getBoolean("autoSync", true)))
    {
      long l1 = System.currentTimeMillis();
      long l2 = App.getSharedPreferences().getLong("whenLastPaused", 0L);
      if (l1 - l2 > 600000L)
        this.d.c();
    }
    this.d.f();
    App.putErrorReporter();
  }

  public final void o()
  {
    if (this.o)
    {
      this.o=false;
      SqliteAppObservable localx1 = thisaf.fSqliteAppObservable.a();
      LoginObservable localal = thisaf.pLoginObservable;
      GlobalVar localh = new GlobalVar(61);
      localal.a(localh);
    }
    else
    {
    	SqliteAppObservable x2;
         if(!thisaf.fSqliteAppObservable.d())
             x2 = thisaf.fSqliteAppObservable.a();
         if(!thisaf.m && !thisaf.n)
         {
        	 thisaf.m=true;
             b b1 = new b(thisaf.h);
             Void[] arrayOfVoid = new Void[0];
             AsyncTask asynctask = b1.execute(arrayOfVoid);
             thisaf.c.b();
         }
    }
  }

  public final void p()
  {
    this.p=true;
    this.pLoginObservable.i();
    this.c.i();
    this.d.i();
    this.fSqliteAppObservable.i();
    this.f.i();
    this.h.i();
    this.j.i();
    this.k.i();
    this.g.i();
    this.l.i();
    this.fSqliteAppObservable.b();
    this.fSqliteAppObservable.c();
  }

  public final String getLoginName()   //old r
  {
    return this.userInfo.getUserName();
  }

  public final String getLoginPass()   //old s
  {
    return this.userInfo.getPassword();
  }

  public final void t()
  {
    this.o=true;
    this.fSqliteAppObservable.b();
  }

  public final boolean isLogined()    //old u
  {
    return this.userInfo.isUser();
  }
}